import unittest
import ddt
from common.base import get_driver
from page.order_list_page import OrderlistPage
from page.login_page import LoginPage
from common.data_operation import DataOperation
from page.index_page import IndexPage
import time
from selenium.webdriver.common.by import By


# data = DataOperation("address_list.csv")
# user_data = data.get_data_to_dict()


class LoginTestCase(unittest.TestCase):
    # user_data = user_data

    @classmethod
    def setUpClass(cls) -> None:
        # 创建浏览器对象
        driver = get_driver()
        # 请求网页
        driver.get(LoginPage.login_url)
        cls.login = LoginPage(driver)
        cls.index = IndexPage(driver)
        cls.order = OrderlistPage(driver)

    # 登录网页
    def test_01_search(self):
        username = 'ab12'
        password = 'abc12345'
        # 登录
        self.login.input_username(username)
        self.login.input_password(password)
        self.login.input_submit()

        # 点击订单页面
        self.order.user()
        self.order.order_list()
        # 返回内容
        test = self.order.get_test()
        # 断言
        self.assertEqual('未付款', test, msg='断言未付款失败')

    @classmethod
    def tearDownClass(cls) -> None:
        cls.order.quit()


if __name__ == '__main__':
    unittest.main(verbosity=2)
